import java.io.*;
import java.net.*;
import java.security.*;
import java.util.*;
import javax.net.*;
import javax.net.ssl.*;

// Extend Browser to use SSL
public class SecureBrowser extends Browser {

	// Must supply URL in command line
	public static void main(String[] args) throws Exception {
		if (args.length != 1) {
			System.out.println("Usage: java SecureBrowser url");
			System.exit(1);
		}
		SecureBrowser browser = new SecureBrowser(args[0]);
		browser.run();
	}

	// Construct a SecureBrowser
	public SecureBrowser(String urlString) {
		super(urlString);
		// Register JSSE
		Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
		// Here's the trick!
		// Simply set the protocol handler property to use SSL.
		System.setProperty("java.protocol.handler.pkgs",
				"com.sun.net.ssl.internal.www.protocol");

//		try {
//			// Make sure that JSSE is available
//			Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
//			// A keystore is where keys and certificates are kept
//			// Both the keystore and individual private keys should be password
//			// protected
//			KeyStore keystore = KeyStore.getInstance("JKS");
//			keystore.load(new FileInputStream(KEYSTORE), KEYSTOREPW);
//			// A KeyManagerFactory is used to create key managers
//			KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
//			// Initialize the KeyManagerFactory to work with our keystore
//			kmf.init(keystore, KEYPW);
//			// An SSLContext is an environment for implementing JSSE
//			// It is used to create a ServerSocketFactory
//			SSLContext sslc = SSLContext.getInstance("SSLv3");
//			// Initialize the SSLContext to work with our key managers
//			sslc.init(kmf.getKeyManagers(), null, null);
//		} catch (Exception e) {
//			System.out.println("error");
//		}

	}
}
